<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li >
                            <label>id：</label>
                            <input type="text" th:value="${id}"  name="id" id="id"  />
                        </li>
                        <li>
                            <label>用户名：</label>
                            <input type="text" name="uName" placeholder="请输入用户名"/>
                        </li>
                        <li>
                            <label>社工名：</label>
                            <input type="text" name="wName" placeholder="请输入社工名"/>
                        </li>
                        <li>
                            <label>项目名：</label>
                            <input type="text" name="iName" placeholder="请输入项目名"/>
                        </li>
                        <li>
                            <label>订单号：</label>
                            <input type="text" name="orderSn" placeholder="请输入订单号"/>
                        </li>
                        <li>
                            <label>状态：</label>
                            <select name="status">
                                <option value="">所有</option>
                                <option value="0">待支付</option>
                                <option value="1">订单提交</option>
                                <option value="2">社工接单</option>
                                <option value="3">社工出发</option>
                                <option value="4">社工到达</option>
                                <option value="5">服务中</option>
                                <option value="6">已完成</option>
                                <option value="7">已取消</option>
                                <option value="8">社工拒绝接单</option>
                            </select>
                        </li>
                        <li>
                            <label>添加时间：</label>
                            <input type="text" class="time-input" placeholder="请选择添加时间" name="addtime"/>
                        </li>
                        <li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="jiajia:order:add">-->
            <!--                <i class="fa fa-plus"></i> 添加-->
            <!--            </a>-->
            <!--            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="jiajia:order:edit">-->
            <!--                <i class="fa fa-edit"></i> 修改-->
            <!--            </a>-->
            <!--            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="jiajia:order:remove">-->
            <!--                <i class="fa fa-remove"></i> 删除-->
            <!--            </a>-->
                        <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="jiajia:order:export">
                            <i class="fa fa-download"></i> 导出
                        </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('jiajia:order:edit')}]];
    var removeFlag = [[${@permission.hasPermi('jiajia:order:remove')}]];
    var prefix = ctx + "jiajia/order";

    $(function () {
        var formData = $("#formId").serializeArray();
        var extParams = {};
        $.each(formData,function(i,v){
            extParams[v.name] = v.value;
        });
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "订单",
            sortName: 'addtime',
            extParams:extParams,
            sortOrder: 'desc',
            pageSize: 20,
            columns: [
                {
                    field: 'uName',
                    title: '用户信息',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push("用户名(id):" + row.uName + '(' + row.uid + ')' + "<br>");
                        actions.push("用户联系电话:" + row.tel + "<br>")
                        // actions.push("地址:" + row.address + "<br>")
                        actions.push("详细地址:" + row.addressDes + "<br>")
                        return actions.join('');
                    }
                },
                {
                    field: 'wName',
                    title: '社工信息',
                    formatter: function (value, row, index) {
                        var actions = [];
                        switch (row.status) {
                            case 0:
                                actions.push("状态:")
                                actions.push("<p style='color:red;display:inline;'>待支付<p/>");
                                break;
                            case 1:
                                actions.push("状态:")
                                actions.push("<p style='color:#ff00ff;display:inline;'>订单提交<p/>");
                                break;
                            case 2:
                                actions.push("状态:")
                                actions.push("<p style='color:#9200ff;display:inline;'>接单<p/>");
                                break;
                            case 3:
                                actions.push("状态:")
                                actions.push("<p style='color:#cda100;display:inline;'>出发<p/>");
                                break;
                            case 4:
                                actions.push("状态:")
                                actions.push("<p style='color:#1bb5d7;display:inline;'>到达<p/>");
                                break;
                            case 5:
                                actions.push("状态:")
                                actions.push("<p style='color:#007665;display:inline;'>服务中<p/>");
                                break;
                            case 6:
                                actions.push("状态:")
                                actions.push("<p style='color:#ff7700;display:inline;'>已完成<p/>");
                                break;
                            case 7:
                                actions.push("状态:")
                                actions.push("<p style='color:darkred;display:inline;'>已取消<p/>");
                                break;
                            case 8:
                                actions.push("状态:")
                                actions.push("<p style='color:#ff0079;display:inline;'>拒绝接单<p/>");
                                break;
                        }
                        actions.push("社工名(id):" + row.wName + '(' + row.wid + ')' + "<br>");
                        actions.push("项目名(id):" + row.iName + '(' + row.iid + ')' + "<br>");
                        return actions.join('');
                    }
                },
                {
                    field: 'iName',
                    title: '订单信息',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push("订单号:" + row.orderSn + "<br>")
                        actions.push("出行方式:")
                        if (row.chuXingPrice == 0) {
                            actions.push('公交地铁' + "<br>")
                        } else {
                            actions.push('出租滴滴' + "<br>")
                        }
                        actions.push("出行费用:" + row.chuXingPrice + "<br>")
                        actions.push("项目金额:" + row.itemPrice + "<br>")
                        actions.push("优惠金额:" + row.youHuiPrice + "<br>")
                        if (row.couponId>0){
                            actions.push("优惠券id:" + row.couponId + "<br>")
                        }
                        actions.push("总金额:" + row.totalPrice + "<br>")
                        actions.push("实付金额:" + row.realPrice + "<br>")



                        return actions.join('');
                    }
                },
                {
                    field: 'orderSn',
                    title: '时间信息',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push("添加时间:" + row.addtime + "<br>");
                        actions.push("开始时间:" + row.starTime + "<br>")
                        actions.push("结束时间:" + row.endtime + "<br>")
                        actions.push("接单时间:" + row.jietime + "<br>")
                        return actions.join('');
                    }
                },
                {
                    field: 'yuyuetime',
                    title: '取消信息',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push("是否评价:")
                        if (row.isPingJia == 0) {
                            actions.push('否' + "<br>")
                        } else {
                            actions.push('是' + "<br>")
                        }
                        actions.push("取消时间:" + row.canceltime + "<br>")
                        actions.push("取消原因:" + row.cancelNote + "<br>");
                        actions.push("取消备注:" + row.cancelContent + "<br>")
                        if(row.cancelUrls!=null){
                            actions.push("取消订单图片:" + '<img  src=' + row.cancelUrls + ' style="width: 50px;height: 50px;" onclick="onLookPhotoListsClick(' + JSON.stringify(row).replace(/"/g, '&quot;') + ')" />' + "<br>")
                        }
                        return actions.join('');
                    }
                },
            ]
        };
        $.table.init(options);
    });

    function onLookPhotoListsClick(row) {
        var data = [];
        var json = {"title": "", "id": 1, "start": 0, "data": data};
        var url = row.cancelUrls;
        data.push({"alt": "", "pid": 0, "src": url, "thumb": url});

        layer.photos({
            photos: json
            , anim: 5
        });
    }
</script>
</body>
</html>